package com.elitecore.servicesImpl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.elitecore.beans.CountryMasterBean;
import com.elitecore.beans.PartnerUser;
import com.elitecore.dao.AuthenticateDAO;
import com.elitecore.dao.CountryDAO;
import com.elitecore.services.AuthenticateService;

@Service("AuthenticateServiceImpl")
public class AuthenticateServiceImpl implements AuthenticateService
{
	private String MODULE =  "AuthenticateServiceImpl";
	private static org.apache.log4j.Logger log	= Logger.getLogger(AuthenticateServiceImpl.class);

	@Autowired
	AuthenticateDAO authenticateDAO;
	
	@Autowired
	@Qualifier("countryDAOImpl")
	private CountryDAO countryDAO;
	
	@Transactional
	public boolean isRegUser(PartnerUser useObj)
	{
		String METHOD = "isRegUser";
		log.info(" in "+METHOD+" of "+MODULE);
		
		if(useObj.getLogin() != null && useObj.getPassword() != null)
		{	
			return authenticateDAO.isRegUser(useObj);
		}
		else
		{
			return false;
		}
	}
	@Transactional
	public List<CountryMasterBean> getAllCountry()
	{
		String METHOD = "getAllCountry";
		log.info(" in "+METHOD+" of "+MODULE);
		
		List<CountryMasterBean> countryList;
		
		try
		{
			countryList = countryDAO.getAllCountry();
			
		}catch(Exception e)
		{
			countryList =  null;
			log.info(" Exception in "+METHOD+" of "+MODULE+e,e);
		}
		return countryList;
	}
}